# Maintainer: George Rawlinson <grawlinson@archlinux.org>
# Contributor: Jan Alexander Steffens (heftig) <jan.steffens@gmail.com>

pkgname=ruby-dbus
pkgver=0.22.1
pkgrel=1
pkgdesc='Ruby module for interaction with D-Bus'
arch=('any')
url='https://github.com/mvidner/ruby-dbus'
license=('LGPL')
depends=('ruby')
makedepends=('git')
options=('!emptydirs')
_commit='5cea356a8b8179d744b8fc302d700ada3601f0a2'
source=("$pkgname::git+$url#commit=$_commit")
b2sums=('SKIP')

pkgver() {
  cd "$pkgname"

  git describe --tags | sed 's/^v//'
}

build() {
  cd "$pkgname"

  gem build "$pkgname.gemspec"
}

package() {
  cd "$pkgname"

  local _gemdir="$(gem env gemdir)"

  gem install \
    --local \
    --verbose \
    --ignore-dependencies \
    --no-user-install \
    --install-dir "$pkgdir/$_gemdir" \
    --bindir "$pkgdir/usr/bin" \
    "$pkgname-$pkgver.gem"

  # delete cache
  rm -rf "$pkgdir/$_gemdir/cache"

  # license
  install -vd "$pkgdir/usr/share/licenses/$pkgname"
  ln -sf "$_gemdir/gems/$pkgname-$pkgver/COPYING" "$pkgdir/usr/share/licenses/$pkgname"
}
